HAL CRYP migration: List of applicable concepts ¶
This section provides information about the HAL CRYP applicable architecture concepts.
Concepts for CRYP ¶
|
Concept |
Description |
|---|---|
|
Provide a dedicated configuration for each algorithm, including only the parameters strictly required by that algorithm. |
|
|
Removal and conversion of init structure to configuration structure |
The init structure has been removed from the handle and converted into set configuration per algorithm function. |
|
The handle structure has been renamed to
|
|
|
The structure
|
|
|
MspInit and MspDeInit are no longer available. They must be replaced by a user sequence to initializes and configures the CRYP or AES. |
|
|
New APIs are available to get and set AES/CRYP features. |
|
|
The
|
|
|
Two functions to set and get user data are available:
|
|
|
Individual callback registration APIs replace global register and unregister functions |
The callback registration is handled by specific functions for each CRYP event. These functions are used to register callback functions for different CRYP events. |
|
|
|
The CRYP and AES state machines have been redesigned to consistently track the operational states and transitions of the peripherals.
|
|
|
The HAL CRYP/AES functions were updated to return:
|
|
|
The HAL error handling mechanisms have been redesigned to improve the detection, reporting, and handling of errors. This provides more detailed and consistent error information. |
|
|
All TypeDef parts of the HAL CRYP driver have been removed and replaced by
|
|
|
For the HAL CRYP driver, large macros have been replaced by inline functions to maintain code consistency, improve readability, and benefit from compiler optimization. Inline functions also offer better support for debugging and strict type management, reducing the risk of errors. |
|
|
Const keywords have been added to non-modifiable pointers to ensure that either the pointer itself or the data it points to cannot be modified. This enhances code safety and readability, prevents unintended modifications, and renders code more robust and maintainable. |
|
|
The parameters and state are checked using
|
|
|
Merge HAL extension files with common ones and remove the EX prefix from APIs. |
Only one HAL CRYP header file remains and all macros, define statements, and functions from
|
|
Introduce a conditional compilation flag
|
|
|
Add ASSERT_DBG_STATE macro controlled by USE_ASSERT_DBG_STATE conditional. |
Introduce a conditional compilation flag
|
|
Replace Finite Parameter Defines (Including PPP Instances) with Enum Types at HAL Levels. |
Finite parameters (including CRYP/AES instances) have been converted into enumerated types (enums) at HAL level. This improves code readability, maintainability, and type safety. |
|
Add HAL_PPP Prefix to All HAL Peripheral APIs (Defines, Macros, Types, and Functions). |
All HAL AES/CRYP enums and struct start with
|
Other HAL CRYP changes ¶
|
Concept |
Consideration |
|---|---|
|
In HAL1 , the main limitation is that a single HAL AES driver is used for all device families, despite differing hardware implementations (AES, SAES, AES, and AES2 (for upcoming products)). |
Provide a dedicated HAL driver for each peripheral:
|
|
Rework the suspend/resume mechanism to avoid saving context within the handle. |
|
|
Use flags compilation to enable supporting the possible algorithms. |
This approach will result in a significant optimization and simplification of the code base. |
|
A new user data format is introduced, where buffers are of type
Endianness and alignment constraints for user data remain unchanged compared to HAL1 and will be detailed in the driver documentation. For migration purposes, user buffers used in HAL1 applications remain valid and compatible with HAL2. |
|
|
Rework the key configuration and setting. |
Separate the key configuration from the global configuration. |
HAL CRYP driver changes ¶
In HAL2, the HAL CRYP driver is split into dedicated HAL drivers for each peripheral, as summarized in the table below
|
peripheral |
HAL1 driver |
HAL2 driver |
|---|---|---|
|
AES SAES |
HAL CRYP |
HAL AES |
|
CRYP |
HAL CRYP |
HAL CRYP |